//
//  TodayViewController.m
//  DUToday
//
//  Created by duyujin1 on 2021/9/2.
//

#import "TodayViewController.h"
#import <NotificationCenter/NotificationCenter.h>

@interface TodayViewController () <NCWidgetProviding>

@end

@implementation TodayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton * button=[[UIButton alloc] initWithFrame:CGRectMake(100, 0, 200, 100)];
    [button setTitle:@"点击跳转" forState:UIControlStateNormal];
    [button setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
    [button addTarget:self action:@selector(_openAPP) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
    // Perform any setup necessary in order to update the view.
    
    // If an error is encountered, use NCUpdateResultFailed
    // If there's no update required, use NCUpdateResultNoData
    // If there's an update, use NCUpdateResultNewData

    completionHandler(NCUpdateResultNewData);
}

-(void)_openAPP{
    [self.extensionContext openURL:[NSURL URLWithString:@"DUAPP://"] completionHandler:^(BOOL success) {
        //
    }];
}

@end
